home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / diskutil / uneekit.zoo / uneekit.c next >
Text File  |  1990-12-10  |  2KB  |  58 lines

  1. /* uneekit.c -- a programme to stamp a new, random, serial number on an Atari
  2.    diskette.  This is specifically for diskettes formatted under MS-DOS, since
  3.    TOS gets confused by their lack of unique serial numbers.
  4.         Ivan D Reid, Untersiggenthal CH  9/12/1990
  5.    ivan@cageir5a.bitnet        20550::ivan    ivan@cvax.psi.ch
  6. */
  7.  
  8. #include    <osbind.h>
  9.  
  10. int    buff[1024];
  11. long    filler;
  12.  
  13. main()
  14. {    register int i;
  15.     register long status;
  16.     register char c;
  17.  
  18. for(;;)        /* loop so we can fix more than one disk */
  19. {    filler=0;
  20.     for (i=0; i<1024; i++)
  21.         buff[i] = 0xdead;    /* fill up array with noticeable pattern */
  22.     i= (Random() & 0x1FL) | '@';    /* random character */
  23.     Cconws("\033E\033e Insert diskette into drive A.\15\12 Press the <");
  24.     Cconout(i);    /* just a little extra to make sure he's thinking */
  25.     Cconws("> key when ready or <Esc> to quit...");
  26.     do
  27.       c=Crawcin()&0x5f;
  28.     while (c != 0x1b && c != i);    /* look for the right key */
  29.  
  30.     if (c == 0x1b)
  31.        break;    /* he wants out... */
  32.     Cconws("\15\12 ");
  33.  
  34.     status = Floprd(buff,filler,0,1,0,0,1);    /* attempt a read */
  35.     if (status)
  36.        Cconws("Error reading boot sector!");
  37.     else
  38.        { i=0;
  39.          while ((buff[i] != 0xdead) && (i<1024))
  40.                i++;    /* see how much we read */
  41.          if (i != 256)
  42.         Cconws("Non-standard sector -- no action.");
  43.          else
  44.         { Protobt(buff,0x1ffffffL,-1,-1);    /* random SN */
  45.           if (Flopwr(buff,filler,0,1,0,0,1))    /* write boot sector */
  46. Cconws("Error writing boot sector. Check write-protection!\15\12");
  47.           else
  48.              Cconws("Diskette now has random serial number.");
  49.         }
  50.        }
  51.     Cconws("\15\12 Press any key to continue (<Esc> quits)...");
  52.     if ((Crawcin()&0x7f)==0x1b)
  53.        break;    /* same deal as above */
  54. }
  55.     Cconws("\33f");    /* turn off cursor */
  56.     exit(0);    /* by-bye */
  57. }
  58. ə